<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <div id="app">{{fullName}}</div>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script>
    const app = new Vue({
      el: "#app",
      data: {
        message: "hello",
        firstName: "Simon",
        lastName: " Brance",
      },
      computed: {
        fullName: {
          get: function() {
            console.log("调用了get()方法-----");
            return this.firstName + this.lastName;
          },
          set: function(value) {
            console.log("调用了set()方法-----", value);
            let names = value.split(" ");
            this.firstName = names[0];
            this.lastName = names[1];
          },
        },
      },
    });
  </script>
</body>

</html>